package com.example.judge.rabbitmq.test;

public class Solution {

    public int twoSum(int var0, int var1) {
        int var2 = var1 + var0;
        return var2;
    }

    public static void main(String[] var0) {
        int var1 = Integer.parseInt(var0[0]);
        int var2 = Integer.parseInt(var0[1]);
        Solution solution = new Solution();
        System.out.println(solution.twoSum(var1, var2));

        String userCode = "public class Solution {\n" +
                "\n" +
                "    public int twoSum(int var0, int var1) {\n" +
                "        int var2 = var1 + var0;\n" +
                "        return var2;\n" +
                "    }\n" +
                "}";

        String mainFunc = "    public static void main(String[] var0) {\n" +
                "        int var1 = Integer.parseInt(var0[0]);\n" +
                "        int var2 = Integer.parseInt(var0[1]);\n" +
                "        Solution solution = new Solution();\n" +
                "        System.out.println(solution.twoSum(var1, var2));\n" +
                "    }";

        String targetCharacter = "}";
        int targetLastIndex = userCode.lastIndexOf(targetCharacter);
        System.out.println(targetLastIndex);
        if (targetLastIndex != -1) {
            // 分割字符串并在目标字符之前插入新字符串
            String newString = userCode.substring(0, targetLastIndex) + "\n" + mainFunc + "\n" + userCode.substring(targetLastIndex);
            System.out.println(newString); // 输出: abcdabcdabc123Pd
        } else {
            System.out.println("目标字符不存在。");
        }


        String str = "abc";
        int i = str.lastIndexOf("%");
        System.out.println(i);
    }
}
